package model.entities.targets;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import util.ColorUtils;

import model.entities.Direction;

public class TransparentTarget implements ITarget {
	
	private Color targetColor;
	private boolean isSatisfied = false;
	private List<Color> incidentColors = new ArrayList<Color>();
	private Color mixedColor;
	
	public TransparentTarget(Color color) {
		this.targetColor = color;
	}

	@Override
	public Direction handleLaserBeam(Direction inDirection, Color beamColor) {
		
		incidentColors.add(beamColor);
		
		mixedColor = ColorUtils.mixColors(incidentColors);
		
		this.isSatisfied = false;
		
		if (mixedColor.equals(targetColor))
			this.isSatisfied = true;
		
		return inDirection.invert(); // transparent
	}

	@Override
	public void handleClick(int button) {
		// TODO Auto-generated method stub
	}

	@Override
	public boolean isSatisfied() {
		return isSatisfied;
	}

	@Override
	public void resetTarget() {
		this.incidentColors.clear();
		this.mixedColor = null;
		this.isSatisfied = false;
	}

	@Override
	public Color getColor() {
		return targetColor;
	}

}
